# 1.编写装饰器，为函数加上统计时间的功能
# import datetime
# def count_run_time(func):
#     def wrap(*args,**kwargs):
#         start_time = datetime.datetime.now()
#         func(*args,**kwargs)
#         end_time = datetime.datetime.now()
#         total_time=(end_time-start_time).total_seconds()
#         print('函数运⾏行行花费了了%f秒。' %
#               (total_time))
#     return wrap
# @count_run_time
# def main():
#     print("开始计算函数运行时间")
#     for i in range(1,1000):
#         for j in range(i):
#             print(j)
# if __name__=="__main__":
#     main()



# 2.编写装饰器，为函数加上认证的功能


def zhuangshiqi(a):
     def yanzheng(*x,**y):
         username= input('请输入账号:')
         passwd= input('请输入密码:')
         if username=='ss' and passwd=='123':
             print('账号密码正确')
             a(*x,**y)
         else:
             print('输入错误')
     return yanzheng
@zhuangshiqi
def my():
    print("日暮途远,人间何世")
    my()



# 3.
class Vahiclse:
    def __init__(self,brand,color):
        self.brand=brand
        self.color=color

    def run(self):
        print("我已经开动了")

    def show_info(self):
        print("车型:%s,颜色:%s"%(self.brand,self.color))

class Car(Vahiclse):
    def __init__(self,brand,color,seats):
        super().__init__(brand,color)
        self.seats=seats

    def show_car(self):
        print("车型:%s,颜色:%s,座位:%d人"%(self.brand,self.color,self.seats))

class Truck(Vahiclse):
    def __init__(self,brand,color,load):
        super().__init__(brand,color)
        self.load=load

    def show_truck(self):
        print("车型:%s,颜色:%s,载重%.2fkg"%(self.brand,self.color,self.load))

c=Car("奔驰","黑色",5)
c.show_car()
c.run()
t=Truck("法拉利","红色",911)
t.show_truck()
